import java.util.HashMap;

import org.graalvm.compiler.graph.Node;
import org.junit.Test;

public class MyTest {
    class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

    private HashMap<Node,Node> hashMap=new HashMap<Node,Node>();
    public Node copyRandomList(Node head) {
        if(head==null){
            return null;
        }
        if(!hashMap.containsKey(head)){
            Node newhead=new Node(head.val);
            hashMap.put(head, newhead);
            newhead.next=copyRandomList(head.next);
            newhead.random=copyRandomList(head.random);
        }
        return hashMap.get(head);
    }

    @Test
    public void test1(){
    }
}

